package com.qst.web;

import com.qst.po.Admin;
import com.qst.service.IAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class AdminController {
    @Autowired
    private IAdminService adminService;
    @RequestMapping("/login")
    public String login(String name, String password, HttpServletRequest request){
        Admin admin = adminService.login(name,password);
        if(admin!=null){
            request.getSession().setAttribute("loginadmin",admin);
            return "home";
        }else{
            request.setAttribute("msg","用户名或者密码错误，请重新登录");
            return "login";
        }
    }
}
